import asyncio

from com.arcfox.middleware.proxy_zhima_middleware import get_proxy_list, format_proxy
from com.arcfox.school.spider.handcollege.hand_enrollment_plan_spider import HandEnrollmentPlanSpider


class HandEnrollmentPlanService:
    def __init__(self):
        self.concurrency = 5

    async def start(self):
        tasks = []
        proxy_list = await get_proxy_list(self.concurrency)
        for proxy in proxy_list:
            tasks.append(asyncio.create_task(HandEnrollmentPlanSpider(format_proxy(proxy)).start_crawl()))
        await asyncio.gather(*tasks)


if __name__ == "__main__":
    asyncio.run(HandEnrollmentPlanService().start())
